package jjn.round2;

import java.util.Stack;

/**
 * @author Jiang Jining
 * @since 2023-05-05 23:36
 */
public class Offer9_CQueue {
    public static class CQueue {
        private final Stack<Integer> first;
        private final Stack<Integer> second;
        
        public CQueue() {
            this.first = new Stack<>();
            this.second = new Stack<>();
        }
        
        public void appendTail(int value) {
            first.push(value);
        }
        
        public int deleteHead() {
            if (!second.isEmpty()) {
                return second.pop();
            }
            if (first.isEmpty()) {
                return -1;
            }
            while (!first.isEmpty()) {
                second.push(first.pop());
            }
            return second.pop();
        }
    }
}
